import request from "@/api";
import { BaseRet, ListRet } from "@/api/response";
import { MenuTypeEnum } from "@/enums/MenuTypeEnum";

class UserMenuApi {
  /**
   * 查询
   * @param id
   * @returns
   */
  static async query(id: string): Promise<ListRet<UserMenu>> {
    return await request({
      url: `sysusermenu/Index/${id}`,
      method: "get",
    });
  }
  /**
   * 新增
   * @param data
   * @returns
   */
  static async create(data: UserMenuCreate): Promise<BaseRet> {
    return await request({
      url: "/sysusermenu/create",
      method: "post",
      data: data,
    });
  }
}

export default UserMenuApi;

export interface UserMenu {
  id: string;
  name: string;
  isCurrentRole: boolean;
  menuType: MenuTypeEnum;
  isRoleMenu: boolean;
  children: UserMenu[];
}

export interface UserMenuCreate {
  userId: string;
  menuIdList: string[];
}
